package com.ruoyi.applet.product.service.impl;

import com.ruoyi.applet.product.domain.ProductSpecifications;
import com.ruoyi.applet.product.mapper.ProductSpecificationsMapper;
import com.ruoyi.applet.product.service.IProductSpecificationsService;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 产品规格Service业务层处理
 * @author ruoyi
 * @date 2024-11-20
 */
@Service
public class ProductSpecificationsServiceImpl implements IProductSpecificationsService {
    
    @Resource
    private ProductSpecificationsMapper productSpecificationsMapper;
    
    /**
     * 查询产品规格
     * @param id 产品规格主键
     * @return 产品规格
     */
    @Override
    public ProductSpecifications selectProductSpecificationsById(Long id) {
        return productSpecificationsMapper.selectProductSpecificationsById(id);
    }
    
    /**
     * 查询产品规格列表
     * @param productSpecifications 产品规格
     * @return 产品规格
     */
    @Override
    public List<ProductSpecifications> selectProductSpecificationsList(ProductSpecifications productSpecifications) {
        return productSpecificationsMapper.selectProductSpecificationsList(productSpecifications);
    }
    
    /**
     * 新增产品规格
     * @param productSpecifications 产品规格
     * @return 结果
     */
    @Override
    public int insertProductSpecifications(ProductSpecifications productSpecifications) {
        productSpecifications.setCreateTime(DateUtils.getNowDate());
        return productSpecificationsMapper.insertProductSpecifications(productSpecifications);
    }
    
    /**
     * 修改产品规格
     * @param productSpecifications 产品规格
     * @return 结果
     */
    @Override
    public int updateProductSpecifications(ProductSpecifications productSpecifications) {
        productSpecifications.setUpdateTime(DateUtils.getNowDate());
        return productSpecificationsMapper.updateProductSpecifications(productSpecifications);
    }
    
    /**
     * 批量删除产品规格
     * @param ids 需要删除的产品规格主键
     * @return 结果
     */
    @Override
    public int deleteProductSpecificationsByIds(String ids) {
        return productSpecificationsMapper.deleteProductSpecificationsByIds(Convert.toStrArray(ids));
    }
    
    /**
     * 删除产品规格信息
     * @param id 产品规格主键
     * @return 结果
     */
    @Override
    public int deleteProductSpecificationsById(Long id) {
        return productSpecificationsMapper.deleteProductSpecificationsById(id);
    }
    
    /**
     * 获取产品规格列表
     * @param productId 产品id
     * @return {@link List<ProductSpecifications>}
     */
    @Override
    public List<ProductSpecifications> selectProductSpecificationsListByProductId(Long productId) {
        return productSpecificationsMapper.selectProductSpecificationsListByProductId(productId);
    }
}
